1 Rmd Settings

2 Contents

  • covid_on_unemp_benefit_numberのOLSとWLS

3 Read functions/関数の読み込み

source("functions.R")

4 Read data/分析用データの読み込み

df_analysis <- readr::read_csv("output/df_analysis.csv")
## Rows: 1551 Columns: 273
## ─ Column specification ────────────────────────────
## Delimiter: ","
## chr    (4): prefec_kanji, prefecture, prefec, prefec_kanji2
## dbl  (268): id, month, year, suicide_total, suicide_male, suicide_female, su...
## date   (1): date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

5 Y = emergency small amount funds/緊急小口の決定件数

6 Y = emergency small amount funds/緊急小口の決定件数 with covar

7 Y= general support funds/総合支援の決定件数

8 Y= general support funds/総合支援の決定件数 with covar

9 Y = housing security benefit/住居確保給付金の決定件数

10 Y = housing security benefit/住居確保給付金の決定件数 with covar

11 Merge outcome results/アウトカム結果の結合

11.1 emergency small amount funds/緊急小口

#merge and label estimates data
estimates_koguchi_number_bind <- dplyr::bind_rows(estimates_koguchi_number_OLS, 
                                               estimates_koguchi_number_WLS)

#change labels and reorder labels
estimates_koguchi_number_bind <- estimates_labeling_poverty(estimates_koguchi_number_bind)

#graph
graph_koguchi_number_bind <- event_study_graph_bind_legend(data = estimates_koguchi_number_bind, 
                                             graph_title = "Emergency Small Amount Funds") +
  theme(legend.position = 'none')

ggplotly(graph_koguchi_number_bind)

11.2 emergency small amount funds/緊急小口 with covar

#merge and label estimates data
estimates_koguchi_number_bind <- dplyr::bind_rows(estimates_koguchi_number_OLS_covar, 
                                           estimates_koguchi_number_WLS_covar)

#change labels and reorder labels
estimates_koguchi_number_bind <- estimates_labeling_poverty(estimates_koguchi_number_bind)

#graph
graph_koguchi_number_bind_covar <- event_study_graph_bind_legend(data = estimates_koguchi_number_bind, 
                                             graph_title = "Emergency Small Amount Funds, with covariates") +
  theme(legend.position = 'none')

ggplotly(graph_koguchi_number_bind_covar)

11.3 general support funds/総合支援

#merge and label estimates data
estimates_sogo_number_bind <- dplyr::bind_rows(estimates_sogo_number_OLS, 
                                               estimates_sogo_number_WLS)

#change labels and reorder labels
estimates_sogo_number_bind <- estimates_labeling_poverty(estimates_sogo_number_bind)

#graph
graph_sogo_number_bind <- event_study_graph_bind_legend(data = estimates_sogo_number_bind, 
                                             graph_title = "General Support Funds") + 
  theme(legend.position = 'none')

ggplotly(graph_sogo_number_bind)

11.4 general support funds/総合支援 with covar

#merge and label estimates data
estimates_sogo_number_bind <- dplyr::bind_rows(estimates_sogo_number_OLS_covar, 
                                               estimates_sogo_number_WLS_covar)

#change labels and reorder labels
estimates_sogo_number_bind <- estimates_labeling_poverty(estimates_sogo_number_bind)

#graph
graph_sogo_number_bind_covar <- event_study_graph_bind_legend(data = estimates_sogo_number_bind, 
                                             graph_title = "General Support Funds, with covariates") +
  theme(legend.position = 'none')

ggplotly(graph_sogo_number_bind_covar)

11.5 housing security benefit/居住確保給付金

#merge and label estimates data
estimates_jukyo_number_bind <- dplyr::bind_rows(estimates_jukyo_number_OLS, 
                                                estimates_jukyo_number_WLS)

#change labels and reorder labels
estimates_jukyo_number_bind <- estimates_labeling_poverty(estimates_jukyo_number_bind)

#graph
graph_jukyo_number_bind <- event_study_graph_bind_legend(data = estimates_jukyo_number_bind, 
                                             graph_title = "Housing Security Benefit") +
  theme(legend.position = 'none')

ggplotly(graph_jukyo_number_bind)

11.6 housing security benefit/居住確保給付金 with covar

#merge and label estimates data
estimates_jukyo_number_bind <- dplyr::bind_rows(estimates_jukyo_number_OLS_covar, 
                                                estimates_jukyo_number_WLS_covar)

#change labels and reorder labels
estimates_jukyo_number_bind <- estimates_labeling_poverty(estimates_jukyo_number_bind)

#graph
graph_jukyo_number_bind_covar <- event_study_graph_bind_legend(data = estimates_jukyo_number_bind, 
                                             graph_title = "Housing Security Benefit, with covariates") +
  theme(legend.position = 'none')

ggplotly(graph_jukyo_number_bind_covar)

11.7 GGplotly

ggplotly(graph_koguchi_number_bind)
ggplotly(graph_koguchi_number_bind_covar)
ggplotly(graph_sogo_number_bind)
ggplotly(graph_sogo_number_bind_covar)
ggplotly(graph_jukyo_number_bind)
ggplotly(graph_jukyo_number_bind_covar)

12 Merge graphs/グラフ統合

12.1 Extract legend/legend取り出し

#Legendの表示

graph_for_legend  <- graph_koguchi_number_bind +
 theme(legend.position = 'bottom', # Adjust x axis label
       legend.title = element_text(color = "black", size = 20),
       legend.text = element_text(color = "black", size = 20))
graph_for_legend  
## Warning: Removed 4 rows containing missing values (geom_point).

#extract legend
legend_model_types <- ggpubr::get_legend(graph_for_legend)
## Warning: Removed 4 rows containing missing values (geom_point).
legend_model_types <- ggpubr::as_ggplot(legend_model_types)
legend_model_types

12.2 Merge/統合

12.2.1 graph size

dpi_num <- 100
width_num <- 15
height_num <- 15
ymin <- - 200
ymax <- 800

ymin_num <- - 200
ymax_num  <- 800
interval <- 200

12.2.2 WLS

graph_koguchi_number_WLS <- graph_koguchi_number_WLS + 
  labs(title = "(a) Emergency Small Amount Funds") + 
  scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_koguchi_number_WLS_covar <- graph_koguchi_number_WLS_covar + 
  labs(title = "(b) Emergency Small Amount Funds, with covariates") + 
  scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_sogo_number_WLS <- graph_sogo_number_WLS + 
  labs(title =  "(c) General Support Funds")+ 
  scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_sogo_number_WLS_covar <- graph_sogo_number_WLS_covar + 
  labs(title = "(d) General Support Funds, with covariates") + 
  scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_jukyo_number_WLS <- graph_jukyo_number_WLS + 
  labs(title = "(e) Housing Security Benefit") + 
  scale_y_continuous(limit = c(-50, 200), breaks=seq(-50, 200, 50))

graph_jukyo_number_WLS_covar <- graph_jukyo_number_WLS_covar + 
  labs(title = "(f) Housing Security Benefit, with covariates") + 
  scale_y_continuous(limit = c(-50, 200), breaks=seq(-50, 200, 50))

graph <- (graph_koguchi_number_WLS | graph_koguchi_number_WLS_covar) / 
  (graph_sogo_number_WLS | graph_sogo_number_WLS_covar) /
    (graph_jukyo_number_WLS | graph_jukyo_number_WLS_covar) 

graph
## Warning: Removed 2 rows containing missing values (geom_point).

## Warning: Removed 2 rows containing missing values (geom_point).

## Warning: Removed 2 rows containing missing values (geom_point).

## Warning: Removed 2 rows containing missing values (geom_point).
## Warning: Removed 12 rows containing missing values (geom_point).

## Warning: Removed 12 rows containing missing values (geom_point).

#保存
ggsave(file = "output/graph_job_seeker_total_shock_on_2nd_safetynet_WLS.pdf", plot = graph, 
       dpi = dpi_num, width = width_num, height = height_num)  
## Warning: Removed 2 rows containing missing values (geom_point).
## Warning: Removed 2 rows containing missing values (geom_point).

## Warning: Removed 2 rows containing missing values (geom_point).

## Warning: Removed 2 rows containing missing values (geom_point).
## Warning: Removed 12 rows containing missing values (geom_point).

## Warning: Removed 12 rows containing missing values (geom_point).

12.2.3 Robustness check

# 2021Feb12Waki


graph_koguchi_number_bind  <- graph_koguchi_number_bind + 
  labs(title = "(a) Emergency Small Amount Funds") + 
  scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_koguchi_number_bind_covar  <- graph_koguchi_number_bind_covar+ 
  labs(title = "(b) Emergency Small Amount Funds, with covariates") + 
  scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_sogo_number_bind  <- graph_sogo_number_bind+ 
  labs(title =  "(c) General Support Funds") + 
  scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_sogo_number_bind_covar  <- graph_sogo_number_bind_covar+ 
  labs(title = "(d) General Support Funds, with covariates") + 
  scale_y_continuous(limit = c(ymin, ymax), breaks=seq(ymin_num, ymax_num, interval))

graph_jukyo_number_bind  <- graph_jukyo_number_bind+ 
  labs(title = "(e) Housing Security Benefit") + 
  scale_y_continuous(limit = c(-50, 200), breaks=seq(-50, 200, 50))

graph_jukyo_number_bind_covar  <-  graph_jukyo_number_bind_covar+ 
  labs(title = "(f) Housing Security Benefit, with covariates") + 
  scale_y_continuous(limit = c(-50, 200), breaks=seq(-50, 200, 50))

graph_2nd_tier_diff_models <-  (graph_koguchi_number_bind + graph_koguchi_number_bind_covar)/
                                (graph_sogo_number_bind + graph_sogo_number_bind_covar)/
                                (graph_jukyo_number_bind + graph_jukyo_number_bind_covar)/legend_model_types + 
plot_layout(heights = c(2,2,2, 0.5))  #0.3から0.5へ変更 2021Sep7 Waki
 
 
graph_2nd_tier_diff_models
## Warning: Removed 4 rows containing missing values (geom_point).

## Warning: Removed 4 rows containing missing values (geom_point).

## Warning: Removed 4 rows containing missing values (geom_point).

## Warning: Removed 4 rows containing missing values (geom_point).
## Warning: Removed 24 rows containing missing values (geom_point).

## Warning: Removed 24 rows containing missing values (geom_point).

#保存
ggsave(file = "output/graph_job_seeker_total_shock_on_2nd_safetynet_robust.pdf", plot = graph_2nd_tier_diff_models, 
       dpi = dpi_num, width = width_num, height = height_num)     
## Warning: Removed 4 rows containing missing values (geom_point).
## Warning: Removed 4 rows containing missing values (geom_point).

## Warning: Removed 4 rows containing missing values (geom_point).

## Warning: Removed 4 rows containing missing values (geom_point).
## Warning: Removed 24 rows containing missing values (geom_point).

## Warning: Removed 24 rows containing missing values (geom_point).

13 Regression table/回帰結果表 without covar

options("modelsummary_format_numeric_latex" = "plain")

# 列の選択 column order

# 緊急小口、総合支援、住居確保、YOYのみ, monthlyhのみ

rows_MONTH <- tribble(~name, ~"(1)", ~"(2)", ~"(3)", ~"(4)", ~"(5)", ~"(6)", 
"Ref. month", "\\footnotesize{Jan.2020}", "\\footnotesize{$\\leq$Jan.2020}",  "\\footnotesize{Jan.2020}", "\\footnotesize{$\\leq$Jan.2020}","\\footnotesize{Jan.2020}", "\\footnotesize{$\\leq$Jan.2020}")

## results list
table_results_MONTH <- list()
table_results_MONTH[["(1)"]] <- results_koguchi_number_WLS
table_results_MONTH[["(2)"]] <- results_koguchi_number_WLS_onlypost
table_results_MONTH[["(3)"]] <- results_sogo_number_WLS
table_results_MONTH[["(4)"]] <- results_sogo_number_WLS_onlypost
table_results_MONTH[["(5)"]] <- results_jukyo_number_WLS
table_results_MONTH[["(6)"]] <- results_jukyo_number_WLS_onlypost

## HTML table
estimates_table_MONTH(df = table_results_MONTH,
                      rows = rows_MONTH,
                      title_words = "UIbenefit",
                      gof = gm,
                      output_style = "html") %>%
    kableExtra::add_header_above(c(" " = 1, "Emergency S.A." = 2, "General Support" = 2, "Housing Security" = 2))

## Latex table
estimates_table_MONTH(df = table_results_MONTH,
                      rows = rows_MONTH,
                      gof = gm,
                      title_words = "DID estimates for suicide rates\\label{tab:DID_unemploy_on_suicide}", 
                      output_style = "latex") %>% 
  kableExtra::add_header_above(c(" " = 1, "Emergency S.A." = 2, "General Support" = 2, "Housing Security" = 2)) %>%
  kableExtra::add_footnote(c("Notes: Robust standard errors are clustered at the prefecture level and the number of clusters (i.e. prefectures) is 47. The treatment variable is the COVID-19-induced employment shock, which is calculated as equation \\eqref{eq:employment_shock}. Estimates are obtained based on equation \\eqref{eq:did_model_ver2} with WLS estimation weighted by prefecture population size."),threeparttable = TRUE, notation = "none",escape = FALSE) %>% 
  kableExtra::column_spec(2:7, width = "1.5cm") %>% 
  kableExtra::save_kable("output/job_seeker_total_shock_on_2nd_safetynet_robust_tables.tex")

14 Regression table/回帰結果表 with covar

# 列の選択 column order

# 緊急小口、総合支援、住居確保、YOYのみ, monthlyhのみ

rows_MONTH <- tribble(~name, ~"(1)", ~"(2)", ~"(3)", ~"(4)", ~"(5)", ~"(6)", 
"Ref. month", "\\footnotesize{Jan.2020}", "\\footnotesize{$\\leq$Jan.2020}",  "\\footnotesize{Jan.2020}", "\\footnotesize{$\\leq$Jan.2020}","\\footnotesize{Jan.2020}", "\\footnotesize{$\\leq$Jan.2020}")

## results list
table_results_MONTH <- list()
table_results_MONTH[["(1)"]] <- results_koguchi_number_WLS_covar
table_results_MONTH[["(2)"]] <- results_koguchi_number_WLS_covar_onlypost
table_results_MONTH[["(3)"]] <- results_sogo_number_WLS_covar
table_results_MONTH[["(4)"]] <- results_sogo_number_WLS_covar_onlypost
table_results_MONTH[["(5)"]] <- results_jukyo_number_WLS_covar
table_results_MONTH[["(6)"]] <- results_jukyo_number_WLS_covar_onlypost

## HTML table
estimates_table_MONTH(df = table_results_MONTH,
                      rows = rows_MONTH,
                      title_words = "UIbenefit",
                      gof = gm,
                      output_style = "html") %>%
    kableExtra::add_header_above(c(" " = 1, "Emergency S.A." = 2, "General Support" = 2, "Housing Security" = 2))

## Latex table
estimates_table_MONTH(df = table_results_MONTH,
                      rows = rows_MONTH,
                      gof = gm,
                      title_words = "DID estimates for suicide rates\\label{tab:DID_unemploy_on_suicide}", 
                      output_style = "latex") %>% 
  kableExtra::add_header_above(c(" " = 1, "Emergency S.A." = 2, "General Support" = 2, "Housing Security" = 2)) %>%
  kableExtra::add_footnote(c("Notes: Robust standard errors are clustered at the prefecture level and the number of clusters (i.e. prefectures) is 47. The treatment variable is the COVID-19-induced employment shock, which is calculated as equation \\eqref{eq:employment_shock}. Estimates are obtained based on equation \\eqref{eq:did_model_ver2} with WLS estimation weighted by prefecture population size."),threeparttable = TRUE, notation = "none",escape = FALSE) %>% 
  kableExtra::column_spec(2:7, width = "1.5cm") %>% 
  kableExtra::save_kable("output/job_seeker_total_shock_on_2nd_safetynet_robust_covar_tables.tex")